<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<%
String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ include file="/pages/login/common.jsp" %>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content="B2B电商平台" name="description"/>
<meta content="B2B电商平台" name="keyword"/>

<title>B2B电商平台.店铺</title>
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/style.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/btn.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/themes.css" />
<link rel="stylesheet" href="<%=path%>/include/JQuery zTree v3.4/css/demo.css">
<link rel="stylesheet" href="<%=path%>/include/JQuery zTree v3.4/css/zTreeStyle/zTreeStyle.css">
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/register_icss.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/sweetalert/sweetalert.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/mmt_trading.css" />
<link rel="stylesheet" href="<%=path %>/include/JQuery ui/select2/css/select2.min.css" type="text/css"></link>

<script type="text/javascript" src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.common.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.shop.apply.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>

<script type="text/javascript" src="<%=path%>/include/JQuery zTree v3.4/js/jquery.ztree.core-3.4.js"></script>
<script type="text/javascript" src="<%=path%>/include/JQuery zTree v3.4/js/jquery.ztree.excheck-3.4.js"></script>

<script type="text/javascript" src="<%=path %>/include/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript" src="<%=path %>/include/sweetalert/sweetalert-dev.js"></script>
<script type="text/javascript" src="<%=path %>/include/JQuery ui/select2/js/select2.min.js"></script>

	<link rel="stylesheet" href="<%=path%>/include/layui/css/layui.css"  media="all">
    <script type="text/javascript" src="<%=path %>/include/layui/lay/dest/layui.all.js" charset="utf-8"></script>
	
<style type="text/css">
body{}
table{border-collapse: collapse;}
tr{ 
    display:block; /*将tr设置为块体元素*/ 
    margin:10px;  /*设置tr间距为2px*/ 
}
td{height:30px; line-height:30px;}
.td1{
	width:100px;
	font-size:14px;
	text-align:right;
	vertical-align: middle;
}
#btnDiv a:hover{
   color:white;
}
button{
    width:44px;
    height:24px;
    line-height:24px;   
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: 0 -203px;
    border:0;
    cursor:pointer;
    font: 12px/1.5 arial,tahoma,\5b8b\4f53;
    margin: 0 0 0 5px;
    outline:none;
    background-image: url('<%=path%>/include/css/img/xs_bgx.png');   
}
.input1{
	width:200px;
	height:30px;
	line-height:30px;
	vertical-align:middle;
	float:left;
}
.select1{
	width: 196px;
    height: 30px;
}
.select2{
    height: 30px;
}

.promptBox{display:inline-block;height:30px;padding-left:5px;width:160px;white-space:nowrap; z-index:50; position:relative;}
.tips-errow{background-position:-296px -22px;color:#f52c2c;}
.tips-ok{background-position:-296px 14px;color:#666;}
.tipsCur{background-position:-296px -55px;color:#666;}
.approveDiv{float:right;color:blue;margin-right:10px;}
</style>
<script type="text/javascript">
	var approveStatus = '${shopInfo.REGISTER_STATUS}';
//	var approveStatus = '1';
	$(function(){
		/*if(approveStatus == ''){
			$("#approveDiv").hide();
		}else if(approveStatus == 0){
			//$("#approveDiv").html("审核状态：待审核");
			//$("#btnDiv").hide();
			//$('input,select,textarea',$('form[name="fm"]')).prop('readonly',true); 
		}else if(approveStatus == 1){
			//$("#approveDiv").html("审核状态：审核通过");
			$("#btnDiv").hide();
			$('input,select,textarea',$('form[name="fm"]')).prop('readonly',true); 
		}else if(approveStatus == 2){
			//$("#approveDiv").html("审核状态：审核不通过");
		}*/
	});

	function saveShop(val){
		if(val=='2') $("#status").val("0");
		if(_checkAllReady()){
			$.ajax({
	              cache: true,
	              type: "POST",
	              url:'<%=path%>/storeApplyAction/saveThr.do',
	              data:$('#fm').serialize(),
	              dataType:"json",
	              error: function(request) {
	                 parent.swal("", "提交失败!", "error");
	              },
	              success: function(data) {
	            	  var msg = data.result;
	            	  if(msg=="保存成功"){
						//parent.swal("", msg, "success");
	                    window.location.href = '<%=path %>/storeApplyAction/toStoreInfo.do?shopId='+data.shopId;
					  }else {
						parent.swal("", msg, "error");
					  }
	              }
	         });
		}
	}

	function _changePro(obj,id,level){
		if(obj.value==""){
			$("#"+id).empty();
			$("#"+id).hide();
			return;
		}
		$.ajax({
              cache: true,
              type: "POST",
              url:'<%=path%>/storeApplyAction/queryProvinceCityList.do',
              data:{areaPcode : obj.value,level:level},
              async: false,
              dataType : 'json',
              error: function(request) {
              },
              success: function(data) {
              	 if(data){
              	 	var list = data;
              	 	if(list.length>0){
						$("#"+id).empty();
						for(var i =0 ;i<list.length;i++){
							var info = list[i];
							var AREA_NAME = info.AREA_NAME;
							var AREA_CODE = info.AREA_CODE;
							$("#"+id).append("<option value='"+AREA_CODE+"'>"+AREA_NAME+"</option>");
						}
						$("#"+id).show();
					}
              	 }
              }
        });
	}

	function _goBack(){
		window.location.href = '<%=path %>/storeApplyAction/getStorePage.do?shopStatus=1&shopId='+$("#shopId").val();
	}

	function _saveBank(){
		$.ajax({
              cache: true,
              type: "POST",
              url:'<%=path%>/storeApplyAction/saveBank.do',
              data:$('#fm').serialize(),
              dataType:"json",
              error: function(request) {
                 parent.swal("", "提交失败!", "error");
              },
              success: function(data) {
            	  var msg = data.result;
            	  if(msg=="保存成功"){
					//parent.swal("", msg, "success");
                    window.location.href = '<%=path %>/storeApplyAction/toStoreInfo.do?status=0&shopId='+data.shopId;
				  }else {
					parent.swal("", msg, "error");
				  }
              }
         });
	}
	
</script>
</head>
<body style="font-family: '微软雅黑'">
	<div id="contentDiv" style="padding:5px; width:99%;margin: 0px;">
		<div style="width:100%;height:30px;border-bottom:1px solid #ADADAD;">
			<div class="toptil">开店申请-开户信息</div>
	 		<div id="approveDiv" class="approveDiv">
	 		</div>
		</div>
		<form id="fm" name="fm" class="form-horizontal form-validate" method="post" action="" novalidate="novalidate">
			<input type="hidden" id="status" name="status" value="${shopInfo.STATUS}">
			<input type="hidden" id="shopId" name="shopId" value="${shopInfo.SHOP_ID }">
			<input type="hidden" id="curPath" name="curPath" value="<%=path %>">
			<input type="hidden" id="showFlag" name="showFlag" value="${showFlag }">
			<div style="width:100%;margin-top:20px;margin-left:10px;">
				<table style="width:100%;">
					<tr>
						<td class="td1" nowrap>开户银行：</td>
						<td class="rightTd" nowrap>
							<select class="select1" id="bankCode" name="bankCode">
							<option value="">---请选择---</option>
							<c:forEach items="${bankList}" var="bank" > 
							<c:if test="${bank.BANK_CODE eq shopInfo.BANK_CODE }">
							<option value="<c:out value='${bank.BANK_CODE }'/>" SELECTED><c:out value='${bank.BANK_NAME }'/></option>
							</c:if>
							<c:if test="${bank.BANK_CODE ne shopInfo.BANK_CODE }">
							<option value="<c:out value='${bank.BANK_CODE }'/>" ><c:out value='${bank.BANK_NAME }'/></option>
							</c:if>
							</c:forEach>
							</select>
							<div class="promptBox">
	                       		<div class='tips-errow' style="display:none;">开户银行已存在</div>
	                       		<div class='tips-ok' style="display:none;"></div>
	                       		<div class='tipsCur' style="display:none;">请选择开户银行</div>
	                       	</div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap>开户银行城市：</td>
						<td class="rightTd" nowrap>
							<select class="select2" id="provinceCode" name="provinceCode" onchange="_changePro(this,'cityCode','3')">
							<option value=""  >---请选择---</option>
								<c:forEach items="${provinceList}" var="province" > 
									<c:if test="${province.AREA_CODE eq shopInfo.BANK_PROVINCE and province.LEVEL eq '2' }">
										<option value="<c:out value='${province.AREA_CODE }'/>" class="<c:out value='${province.IF_ZXS }'/>" SELECTED><c:out value='${province.AREA_NAME }'/></option>
									</c:if>
									<c:if test="${province.AREA_CODE ne shopInfo.BANK_PROVINCE and province.LEVEL eq '2' }">
										<option value="<c:out value='${province.AREA_CODE }'/>" class="<c:out value='${province.IF_ZXS }'/>" ><c:out value='${province.AREA_NAME }'/></option>
									</c:if>
								</c:forEach>
							</select>
							<select class="select2" id="cityCode" name="cityCode" <c:if test="${fn:length(bankCityList) eq 0}">style="display:none;"</c:if>>
								<c:forEach items="${bankCityList}" var="city" > 
									<option value="${city.AREA_CODE }" <c:if test="${city.AREA_CODE eq shopInfo.BANK_CITY}">selected="selected"</c:if>>${city.AREA_NAME }</option>
								</c:forEach>
							</select>
							<div class="promptBox">
	                       		<div class='tips-errow' style="display:none;">开户银行城市已存在</div>
	                       		<div class='tips-ok' style="display:none;"></div>
	                       		<div class='tipsCur' style="display:none;">请选择开户银行城市</div>
	                       	</div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap>开户人姓名：</td>
						<td class="rightTd" nowrap>
							<input class="input1" id="bankAccountName" name="bankAccountName" value="${shopInfo.BANK_ACCOUNT_NAME }">
							<div class="promptBox">
	                       		<div class='tips-errow' style="display:none;">开户人姓名已存在</div>
	                       		<div class='tips-ok' style="display:none;"></div>
	                       		<div class='tipsCur' style="display:none;">请输入开户人姓名</div>
	                       	</div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap>对公账户：</td>
						<td class="rightTd" nowrap>
							<input class="input1" id="bankAccount" name="bankAccount" value="${shopInfo.BANK_ACCOUNT }">
							<div class="promptBox">
	                       		<div class='tips-errow' style="display:none;">对公账户不符合规则</div>
	                       		<div class='tips-ok' style="display:none;"></div>
	                       		<div class='tipsCur' style="display:none;">请输入对公账户</div>
	                       	</div>
						</td>
					</tr>
					<tr>
						<td class="td1">&nbsp;</td>
						<td style="">
							<c:if test="${showFlag ne '1'}">
								<div id="btnDiv" style="float: left;">
									<a onclick="_goBack();" class="btn btn-primary" style="text-decoration:none;">上一步</a>
								</div>
								<div id="btnDiv" style="float: left;margin-left: 15px;">
									<a onclick="saveShop('1');" class="btn btn-primary" style="text-decoration:none;">提交</a>
								</div>
							</c:if>
							<c:if test="${showFlag eq '1'}">
								<div id="btnDiv" style="float: left;">
									<a onclick="_saveBank();" class="btn btn-primary" style="text-decoration:none;">保存</a>
								</div>
								<c:if test="${shopInfo.STATUS eq '2'}">
									<div id="btnDiv" style="float: left;margin-left: 15px;">
										<a onclick="saveShop('2');" class="btn btn-primary" style="text-decoration:none;">提交</a>
									</div>
								</c:if>
							</c:if>
						</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
					</tr>
				</table>
			</div>
		</form>
	</div>
</body>
<script type="text/javascript">
	$(document).ready(function(){
		_reHeight();
		$("#bankCode").select2();
	});
	function _reHeight(){
		var main = $(window.parent.document).find("#rightFrame");
		var mainheight = $("#contentDiv").height();
		main.height(mainheight);
	}
	
	function hideMenu() {
		$("#menuContent").fadeOut("fast");
		$("body").unbind("mousedown", onBodyDown);
	}
	
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
			hideMenu();
		}
	}
	
	function showMenu() {
		var cityObj = $("#citySel");
		var cityOffset = $("#citySel").offset();
		$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
		$("body").bind("mousedown", onBodyDown);
	}
	//加载失败提示  
    function zTreeOnAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {  
        parent.swal("", "经营区域加载失败，请稍后再试", "info");
    }; 
</script>
</html>
